<template>
  <!--测试-->
  <div style="text-align: left;padding-right:0" :style="{'background' : color}">
    <div  style=" height: 1.3rem" >
      <slot name="title"></slot>
      <span @click="isShow= !isShow" class="cjy-der-down" :class="{'cjy-der-right' :isShow}">去选择</span>
      <div style="clear: both"></div>
    </div>
    <transition enter-active @beforeEnter="beforeEnter" @enter="enter" @leave="leave">
      <div v-show="isShow" class="cjy-show-Box">
       <slot name="content"></slot>
      </div>
    </transition>
  </div>
</template>

<script>
  // import Hello from './components/Hello'

  export default {
    data () {
      return {
        isShow: false,
        boxHeight:1.6
      }
    },

    components: {},
    props: {
      color:{
        type : String,
        default: 'rgba(255, 245, 184, 0.55)'

      }
    },
    methods: {
      beforeEnter (el, done) {
        el.style.height = 0
      },
      enter (el, done) {
        var H = 0
        var timeOut = setInterval(() => {
          H += 0.08
          el.style.height = H + 'rem'

          if (H > this.boxHeight) {
            done()
            clearTimeout(timeOut)
          }
        }, 1)
      },
      leave (el, done) {
        var H =  this.boxHeight
        var timeOut = setInterval(() => {
          H -= 0.08
          el.style.height = H + 'rem'

          if (H <= 0) {
            done()
            clearTimeout(timeOut)
          }
        },1)
      }
    }
  }
</script>

<style scoped>
  .cjy-sec-title {
    max-width: 60%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    margin-left: 0.5rem;
    vertical-align: middle;
  }

  .preferential {

    padding:0!important;
    line-height: 1rem;
  }

  .preferential a {
    margin-top: 0.2rem;
    padding-right: 1rem;
  }

  .preferential .cjy-span, .preferential .cjy-add-sub {
    float: right;
    padding-right: 0.75rem;
    color: #EF5423;
    margin-top: 0.2rem;
  }

  .cjy-add-sub-showNumb {
    height: 100%;
    width: 1rem;
    text-align: center;
    vertical-align: middle;
    float: right;
  }

  .cjy-add-button, .cjy-sub-button {
    border: 1px solid rgb(234, 57, 57);
    border-radius: 50%;
    height: 1rem;
    width: 1rem;
    display: block;
    position: relative;
  }

  .cjy-add-button::after, .cjy-sub-button::after {
    content: '';
    width: 0.6rem;
    height: 0rem;
    border-top: thin solid rgb(234, 57, 57);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }

  .cjy-sub-button {
    border: 1px solid gray;
  }

  .cjy-sub-button::after {
    border-top: thin solid gray;
  }

  .cjy-add-button::before {
    content: '';
    width: 0;
    height: 0.6rem;
    border-left: thin solid rgb(234, 57, 57);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }

  .cjy-button-box {
    float: right;

    padding: 2px;
  }

  .cjy-right {
    float: right !important;
    color: rgb(234, 57, 57);
  }

  .cjy-der-down {
    line-height: 1.3rem;
    padding-right:1rem;
    position: relative;
    display: inline-block;
    float: right !important;
    color: rgb(234, 57, 57);
    margin-right: 0.3rem;
  }

  .cjy-der-down:before {
    content: '';
    width: 0.4rem;
    height: 0.4rem;
    position: absolute;
    top: 47%;
    right: 0.3rem;
    margin-top: -0.2rem;
    background: transparent;
    border: 1px solid rgb(234, 57, 57);
    border-top: none;
    border-right: none;
    z-index: 2;
    -webkit-border-radius: 0;
    border-radius: 0;
    -webkit-transform: rotate(-135deg);
    transition: 0.3s;
    transform: rotate(-135deg);

  }
  .cjy-der-right:before {
    -webkit-transform: rotate(-45deg);
    transform: rotate(-45deg);
  }
  .cjy-show-Box {
    overflow: hidden;
    padding: 0 0.5rem;
  }

  .cjy-show-regular-detail {
    padding: 0.2rem 0.3rem 0.2rem 0;
    border-top: 1px dashed gainsboro;
    height: 1.5rem;
  }



</style>
